package com.action;

import com.entity.Coach;
import com.entity.Comment;
import com.service.CoachService;
import com.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import java.util.List;


@Controller
@Scope("prototype")
public class CommentAction extends BaseAction
{

    @Autowired
    private CommentService commentService;
    @Autowired
    private CoachService coachService;


    private CommentAction commentAction;
    private Comment comment;

    //作用域
    private List<Comment> comments;

    private Integer id;

    public String listById()
    {
        comments=commentService.getAllComment(id);
        return "coumentListJson";
    }

    public String add()
    {
        Coach coach=coachService.getCoachById(id);
        comment.setCoach(coach);
        commentService.addComment(comment);
        return "index";
    }

    public CommentAction getCommentAction() 
    {
        return commentAction;
    }

    public void setCommentAction(CommentAction commentAction) 
    {
        this.commentAction = commentAction;
    }

    public Integer getId() 
    {
        return id;
    }

    public void setId(Integer id) 
    {
        this.id = id;
    }

    public List<Comment> getComments() 
    {
        return comments;
    }

    public void setComments(List<Comment> comments) 
    {
        this.comments = comments;
    }

    public Comment getComment() 
    {
        return comment;
    }

    public void setComment(Comment comment) 
    {
        this.comment = comment;
    }
}
